﻿using System;
using System.Collections.Generic;
using ProjectHopur23;
using ProjectHopur23.Models;
using ProjectHopur23.Repositories;

namespace ProjectHopur23.Tests.Repositories
{
	///<summary>A test repo class with hardcoded info, will be used for unit testing and testing in general</summary>
	public class TestRepository : IRepository
   	{
		#region Variables
		List<Game> allGames = new List<Game>();
		List<ActiveGame> allActiveGames = new List<ActiveGame>();
		List<Player> allPlayers = new List<Player>();
		List<UserProfile> allUsers = new List<UserProfile>();
		List<TicTacToeState> allTicTacToeStates = new List<TicTacToeState>();
		List<LudoState> allLudoStates = new List<LudoState>();
		List<Invite> allInvites = new List<Invite>();
		List<DieValue> allDieValues = new List<DieValue>();
		List<Comment> allComments = new List<Comment>();
		#endregion

		#region Functions
		public IEnumerable<Game> GetAllGames()
		{
			Game g1 = new Game();
			g1.ID = 1;
			g1.name = "Mylla";
			g1.engName = "TicTacToe";
			g1.description = "Mylluleikur";
			g1.imageURL = "~/Images/tictactoe.png";
			g1.minPlayers = 2;
			g1.maxPlayers = 2;
			g1.timesPlayed = 24369;

			Game g2 = new Game();
			g2.ID = 5;
			g2.name = "Lúdó";
			g2.engName = "Ludo";
			g2.description = "Lúdóleikur";
			g2.imageURL = "~/Images/ludo.png";
			g2.minPlayers = 2;
			g2.maxPlayers = 4;
			g2.timesPlayed = 1114;

			allGames.Add(g1);
			allGames.Add(g2);

			return allGames;
		}

		public IEnumerable<ActiveGame> GetAllActiveGames()
		{
			allActiveGames.Add(new ActiveGame {ID = 1, gameId = 1, name = "Unittest", isFinished = false, isFull = false, isOpen = true, numberOfPlayers = 2});

			return allActiveGames;
		}

		public IEnumerable<Player> GetAllPlayers()
		{
			allPlayers.Add(new Player {playerId = 0, activeGameId = 1, userId = 3});

			return allPlayers;
		}

		public IEnumerable<UserProfile> GetAllUsers()
		{
			allUsers.Add(new UserProfile {UserId = 1, UserName = "Duddi67", email = "duddi@duddi.is", score = 0});

			return allUsers;
		}

		public IEnumerable<TicTacToeState> GetAllTicTacToeStates()
		{
			return allTicTacToeStates;
		}

		public IEnumerable<LudoState> GetAllLudoStates()
		{
			return allLudoStates;
		}

		public IEnumerable<Invite> GetAllInvites()
		{
			allInvites.Add(new Invite {activeGameId = 1, hostId = 2, guestId = 3, isToggled = false, isAccepted = false});

			return allInvites;
		}

		public IEnumerable<DieValue> GetAllDieValues()
		{
			return allDieValues;
		}

		public IEnumerable<Comment> GetAllComments()
		{
			return allComments;
		}

		public void AddGame(Game g)
		{
			allGames.Add(g);
		}

		public void AddActiveGame(ActiveGame ag)
		{
			allActiveGames.Add(ag);
		}

		public void AddPlayer(Player p)
		{
			allPlayers.Add(p);
		}

		public void AddUser(UserProfile u)
		{
			allUsers.Add(u);
		}

		public void AddTicTacToeState(TicTacToeState t)
		{
			allTicTacToeStates.Add(t);
		}

		public void AddLudoState(LudoState l)
		{
			allLudoStates.Add(l);
		}

		public void AddInvite(Invite i)
		{
			allInvites.Add(i);
		}

		public void AddDieValue(DieValue dv)
		{
			allDieValues.Add(dv);
		}

		public void AddComment(Comment c)
		{
			allComments.Add(c);
		}

		public void Save()
		{
			// Nothing to do here
		}
		#endregion
	}
}